$(document).ready(function () {

    $("#sub_register").off('click').on('click', function () {
        $.ajax({
            url: 'user/doregister',
            type: 'post',
            data: $("#form_register").serialize(),
            success: function (result_data) {
                if (result_data == 1) {
                    window.location.href = "index";
                }
                if (result_data == 0) {
                    window.location.href = "index";
                }
            }
        });
        return false;
    });


    $("#sub_login").on('click', function () {
        var data = $("#form_login").serialize()
        console.log(data)
        $.ajax({
            url: 'dologin/',
            type: 'post',
            data: data,
            success: function (result_data) {
                if (result_data == 1) {
                    window.location.href = "index";
                }
                if (result_data == 2) {
                    window.location.href = "login";
                }
                if (result_data == 3) {
                    window.location.href = "login";
                }
            }
        });
        return false;
    });


});